package searchtab.views;

import org.eclipse.ui.IPartListener;
import org.eclipse.ui.IWorkbenchPart;

import searchtab.SearchTabActivator;

class SearchTabViewListener implements IPartListener {

    public void partOpened(IWorkbenchPart workbenchPart) {

    }

    public void partDeactivated(IWorkbenchPart workbenchPart) {
    }

    public void partClosed(IWorkbenchPart workbenchPart) {
        if (!checkView(workbenchPart)) {
            return;
        }
        SearchTabActivator.getDefault().getSearcherEngine().unmarkResults();
    }

    public void partBroughtToTop(IWorkbenchPart workbenchPart) {
    }

    public void partActivated(IWorkbenchPart workbenchPart) {
    }

    private boolean checkView(IWorkbenchPart workbenchPart) {
        return workbenchPart.getSite().getPluginId().equals(SearchTabActivator.PLUGIN_ID);
    }
}